package com.example.bookseckill.service.Impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.bookseckill.entity.OrderEntity;
import com.example.bookseckill.entity.to.mq.SeckillOrderTo;
import com.example.bookseckill.mapper.OrderDao;
import com.example.bookseckill.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import cn.hutool.core.date.DateUtil;

import java.util.Date;

@Slf4j
@Service("orderService")
public class OrderServiceImpl extends ServiceImpl<OrderDao,OrderEntity> implements OrderService {
    /**
     * 创建秒杀单
     * @param orderTo
     */
    @Override
    public void createSeckillOrder(SeckillOrderTo orderTo) {
        OrderEntity orderEntity = new OrderEntity();
        orderEntity.setOrderSn(orderTo.getOrderSn());
        orderEntity.setCreateTime(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));

        //保存订单
        this.save(orderEntity);
    }
}
